﻿using Bll;
using Common;
using CommonModel.Config;
using System;
using System.Net;
using System.Net.Sockets;
using Thrift.Server;
using Thrift.Transport;

namespace ThriftServer
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Console.Title = "ThriftServer";
                TServerSocket serverTransport = new TServerSocket(new TcpListener(IPAddress.Parse(RpcConfig.HostName), int.Parse(RpcConfig.Port)));
                IRpcBll.Processor processor = new IRpcBll.Processor(new RpcBll());
                TServer server = new TThreadPoolServer(processor, serverTransport);

                Console.WriteLine("启动ThriftServer，监听IP：" + RpcConfig.HostName + "      监听端口" + RpcConfig.Port + "...");
                server.Serve();
            }
            catch (Exception ex)
            {
                LogHelper.Error("报错：" + ex);
            }
            Console.WriteLine("程序已停止运行，按任意键结束");
            Console.ReadKey();
        }
    }
}
